﻿@model CmsUserContainer
@{
    ResFile = "cms_Users";
}
<fieldset class="b-form b-form__userdetails">
    <ol class="b-form__rows ul-reset g-clear">
        <li class="b-form__row g-clear">
            @if (Model.IsNew)
            {         
                <label for="LoginName">@_("Login")<span class="b-error-notice_title">*</span></label>
                @Html.TextBoxFor(p => p.LoginName, new { @class = "text" })
                @Html.ValidationMessageFor(p => p.LoginName)         
            }
            else
            {
                <label>@_("User/login name")</label>
                <span>@Model.LoginName</span>
            }
        </li>
        <li class="b-form__row g-clear">
            <label for="UserEmail">@_("Email")<span class="b-error-notice_title">*</span></label>
            @Html.TextBoxFor(p => p.UserEmail, new { @class = "text" })
            @Html.ValidationMessageFor(p => p.UserEmail)
        </li>
        <li class="b-form__row g-clear">
            <label for="Firstname">@_("Firstname")<span class="b-error-notice_title">*</span></label>
            @Html.TextBoxFor(p => p.Firstname, new { @class = "text" })
            @Html.ValidationMessageFor(p => p.Firstname)
        </li>
        <li class="b-form__row g-clear">
            <label for="Lastname">@_("Lastname")<span class="b-error-notice_title">*</span></label>
            @Html.TextBoxFor(p => p.Lastname, new { @class = "text" })
            @Html.ValidationMessageFor(p => p.Lastname)
        </li>
        @if (Model.AvailableLanguages.Any())
        {
            <li class="b-form__row g-clear">
                <label for="Locale">@_("Language")</label>
                @Html.DropDownListFor(p => p.Locale, new SelectList(Model.AvailableLanguages, "CultureName", "SystemLanguageName"), _("Please select"), new {@class = "select"})
                @Html.ValidationMessageFor(p => p.Locale)
            </li>
        }

        @if (Model.IsCanSetPassword)
        { 
            <li class="g-clear">
                <li>
                    <ol class="b-form__rows ul-reset g-clear">
                        <li class="b-form__row g-clear">
                            @if (Model.Id > 0)
                            {
                                <label for="IsChangePassword">@_("Change password")</label>
                                @Html.CheckBoxFor(p => p.IsChangePassword, new Dictionary<string, object> { { "class", "js-set-password-checkbox" }, { "data-invert", "true" } })
                            }
                            else
                            {
                                <label for="IsAutoGeneratePassword">@_("Auto generate password")</label>
                                @Html.CheckBoxFor(p => p.IsAutoGeneratePassword, new { @class = "js-set-password-checkbox" })
                            }
                        </li>
                    </ol>
                    <div class="hide js-password-section">
                        <ol class="b-form__rows ul-reset g-clear">
                            <li class="b-form__row g-clear">
                                <label for="NewPassword">@_("New password")<span class="b-error-notice_title">*</span></label>
                                @Html.Password("NewPassword", "", new { @class = "text" })
                                @Html.ValidationMessageFor(m => m.NewPassword)
                            </li>
                            <li class="b-form__row g-clear">
                                <label for="ReNewPassword">@_("Retype new password")<span class="b-error-notice_title">*</span></label>
                                @Html.Password("ReNewPassword", "", new { @class = "text" })
                                @Html.ValidationMessageFor(m => m.ReNewPassword)
                            </li>
                            <li class="b-form__row g-clear">
                                <label for="IsSendEmail">@_("Send email")</label>
                                @Html.CheckBoxFor(p => p.IsSendEmail)
                            </li>
                        </ol>
                    </div>
                </li>
            </li>
        }

        <li class="b-form__row g-clear">
            <label for="IsEnabled">@_("Enabled")</label>
            @Html.CheckBoxFor(p => p.IsEnabled)
        </li>

        <li class="g-clear">
            @Html.Action("EntityMetaValues", "CmsMetaField", new { metaInformation = Model.EntityMetaInformation, isValid = ViewData.ModelState.IsValid })
        </li>

        @(Html.UserGroupPlaceholder().ForUserGroups(PredefinedUserGroups.Developer).Template(
              @<text>
        <li class="b-form__row g-clear">
            <label>@_("User scope")</label>
            @Html.Partial("SiteAwarePlug", Model)
        </li>
        </text>)
              .AlternativeTemplate(
                  @<text>
        <li class="b-form__row g-clear" style="display: none">
            @Html.Partial("SiteAwarePlug", Model)
        </li>
        </text>)
              .Render())
    </ol>
</fieldset>
